import request from '@/utils/request'

// 登录
export const login = (obj) => request.post('login', obj)
// 获取菜单项
export const getMenuList = () => request.get('menus')
// 获取用户列表
export const getUserList = (obj) => request.get('users', { params: obj })
// 修改用户状态
export const editUserStatus = (id, type) => request.put(`users/${id}/state/${type}`)
// 添加新用户
export const addUser = (obj) => request.post('users', obj)
// 根据id获取用户信息
export const findUser = (id) => request.get(`users/${id}`)
// 修改用户信息
export const editUser = (id, obj) => request.put(`users/${id}`, obj)
// 分配角色
export const saveRole = (id, rid) => request.put(`users/${id}/role`, { rid })
// 删除用户
export const delUser = (id) => request.delete(`users/${id}`)
// 获取用户列表
export const getRightsList = () => request.get('rights/list')
// 获取角色列表
export const getRolesList = () => request.get('roles')
// 删除角色权限
export const delRightById = (rolesId, rightId) => request.delete(`roles/${rolesId}/rights/${rightId}`)
// 获取所有权限
export const getRights = () => request.get('rights/tree')
// 分配权限
export const setRoleRights = (id, rids) => request.post(`roles/${id}/rights`, { rids })
// 添加角色
export const addRole = (obj) => request.post('roles', obj)
// 修改角色
export const editRole = (id, obj) => request.put(`roles/${id}`, obj)
// 删除角色
export const delRole = (id) => request.delete(`roles/${id}`)

// 商品分类
export const getCateList = (obj) => request.get('categories', { params: obj })
// 添加分类
export const addCateGories = (obj) => request.post('categories', obj)
// 编辑分类
export const editCateGories = (id, name) => request.put(`categories/${id}`, { cat_name: name })
// 删除分类
export const deleteCateGories = (id) => request.delete(`categories/${id}`)

// 获取分类参数
export const getCateParams = (id, sel) => request.get(`categories/${id}/attributes`, { params: { sel } })
// 添加动态参数或静态属性
export const addCateParams = (id, name, sel) => request.post(`categories/${id}/attributes`, { attr_name: name, attr_sel: sel })
// 修改参数
export const editCateParams = ({ cid, attrId }, { name, sel, vals = null }) => request.put(`categories/${cid}/attributes/${attrId}`, { attr_name: name, attr_sel: sel, attr_vals: vals })
// 删除参数
export const delCateParams = ({ cid, attrId }) => request.delete(`categories/${cid}/attributes/${attrId}`)

// 获取商品列表
export const getGoodsList = (obj) => request.get('goods', { params: obj })
// 删除商品
export const removeGoods = (id) => request.delete(`goods/${id}`)
// 添加商品
export const addGood = (obj) => request.post('goods', obj)

// 订单数据列表
export const getOrdersList = (obj) => request.get('orders', { params: obj })
// 查看物流
export const showKuaidi = () => request.get('/kuaidi/1106975712662')

// 基于时间的数据统计
export const getReports = () => request.get('reports/type/1')
